lexer grammar XMLLexer;

//default mode
OPEN    :   '<'                 -> pushMode(INSIDE);
COMMENT:    '<!--' .*? '-->'      -> skip;
EntityRef:  '&' [a-z]+ ';';
//match any 16 bit char minus < and &
TEXT:       ~('<'|'&')+;


//inside of tag
mode INSIDE;
CLOSE:          '>'             -> popMode;
SLASH_CLOSE:    '/>'            -> popMode;
EQUALS:         '=';
STRING:         '"'.*?'"';
SlashName:      '/' Name;
Name:           ALPHA (ALPHA|DIGIT)*;
S:              [ \t\r\n]       -> skip;

fragment
ALPHA:          [a-zA-Z];

fragment
DIGIT:          [0-9];